$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require "test/unit"
require "helper_autoit"

class AutoItTest < Test::Unit::TestCase
  $autoit = WIN32OLE.new "AutoItX3.Control"

  def test_type
    a = AutoIt.new
    a.run("", "notepad")
    a.type({"title" => "Untitled -", "target" => "", "controlID" => "Edit1"}, "this is for testing Autoit.type")
    assert_equal("this is for testing Autoit.type", $autoit.ControlGetText("Untitled -", "", "Edit1"))
    a.kill_process("notepad.exe")
  end

  def test_control_click
    a = AutoIt.new
    a.run("", "C:\Program Files\\Internet Explorer\\iexplore.exe")
    a.win_activate("Google", "")
    a.click({:title =>"", :text=>"",:controlID=>"ToolbarWindow322", :button=>"", :clicks=>"1", :x=>40, :y=>14},"")
  end

  def test_menu_click
    a = AutoIt.new()
    a.run("", "notepad")
    a.win_activate("Untitled", "")
    a.win_menu_click("Untitled", "", "&File", "&Open...")
  end

  def test_send_key
    a = WIN32OLE.new "AutoItX3.Control"
    a.Send("d")
  end
end